﻿using System;
using System.Globalization;
using System.Web.UI.WebControls;


namespace DotNetNuke.Modules.UserDefinedTable
{


  public class EditInt32 : EditString
  {


    //public EditInt32()
    //{
    //  base.Init += new EventHandler(this.EditInt32_Init);
    //}



    protected override void OnInit(EventArgs e)
    {
      base.OnInit(e);
      //base.Init += new EventHandler(this.EditInt32_Init);
      base.ctlValueBox.Attributes.Add("style", "text-align:right");
      Unit unit2 = new Unit("10em");
      base.ctlValueBox.Width = unit2;

    }




    //private void EditInt32_Init(object sender, EventArgs evt)
    //{
    //  base.ctlValueBox.Attributes.Add("style", "text-align:right");
    //  Unit unit2 = new Unit("10em");
    //  base.ctlValueBox.Width = unit2;
    //}





    protected override bool IsValidType()
    {
      int num;
      if ( !string.IsNullOrEmpty(this.Value) && !int.TryParse(this.Value, out num) )
        return false;

      return true;
    }




    public override string Value
    {
      get
      {
        string str;
        try
        {
          str = string.Empty;
          if (base.Value != "")
          {
            str = base.Value.ToString();
          }
        }
        catch (Exception e)
        {
          
          str = base.Value;
          
        }
        return str;
      }
      set
      {
        CultureInfo provider = new CultureInfo("en-US");
        if (value != "")
        {
          value = int.Parse(value, provider).ToString("#,###,###,##0");
        }
        base.Value = value;
      }
    }



  }

}

